Question1: Which sentence describes the following regular expression match?
preg_match('/^\d+(?:\.[0-9]+)?$/', $test);
Question2: Which of the following code snippets DO NOT write the exact content of the file "source.txt" to "target.txt"?
(Choose 2)
Question3: Which of the following will set a 10 seconds read timeout for a stream?
Question4: What is "instanceof" an example of?
Question5: You need to escape special characters to use user input inside a regular expression. Which functions would you use? (Choose 2)
Question6: Which one of the following XML declarations is NOT valid?
Question7: Which of the following statements are FALSE?
Question8: Which of the following are valid identifiers? (Choose 3)
Question9: What is the output of the following code?
class Number {
private $v;
private static $sv = 10;
public function __construct($v) { $this->v = $v; }
public function mul() {
return static function ($x) {
return isset($this) ? $this->v*$x : self::$sv*$x;
};
}
}
$one = new Number(1);
$two = new Number(2);
$double = $two->mul();
$x = Closure::bind($double, null, 'Number');
echo $x(5);
Question10: What is the output of the following code?
$a = 'a'; $b = 'b';
echo isset($c) ? $a.$b.$c : ($c = 'c').'d';
Question11: The following form is loaded in a browser and submitted, with the checkbox activated:
<form method="post">
<input type="checkbox" name="accept" />
</form>
In the server-side PHP code to deal with the form data, what is the value of $_POST['accept'] ?
Question12: What is the method used to execute XPath queries in the SimpleXML extension?
Question13: What types of HTTP authentication are supported by PHP? (Choose 2)
Question14: Which interfaces could class C implement in order to allow each statement in the following code to work?
(Choose 2)
$obj = new C();
foreach ($obj as $x => $y) {
echo $x, $y;
}
Question15: What is the name of the function that allows you register a set of functions that implement user-defined session handling?
Question16: What can prevent PHP from being able to open a file on the hard drive (Choose 2)?
Question17: What is the output of the following code?
class a
{
public $val;
}
function renderVal (a $a)
{
if ($a) {
echo $a->val;
}
}
renderVal (null);
Question18: What is cached by an opcode cache?
Question19: Consider the following table data and PHP code, and assume that the database supports transactions.
What is the outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna [email protected]
2 betty [email protected]
3 clara [email protected]
5 sue [email protected]
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
try {
$pdo->exec("INSERT INTO users (id, name, email) VALUES (6, 'bill', '[email protected]')");
$pdo->begin();
$pdo->exec("INSERT INTO users (id, name, email) VALUES (7, 'john', '[email protected]')"); throw new Exception();
} catch (Exception $e) {
$pdo->rollBack();
}
Question20: What super-global should be used to access information about uploaded files via a POST request?
Question21: What is the output of the following code?
var_dump(boolval(new StdClass()));
Question22: How many elements does the array $pieces contain after the following piece of code has been executed?
$pieces = explode("/", "///");
Question23: How should class MyObject be defined for the following code to work properly? Assume $array is an array and MyObject is a user-defined class.
$obj = new MyObject();
array_walk($array, $obj);
Question24: Given a DateTime object that is set to the first second of the year 2014, which of the following samples will correctly return a date in the format '2014-01-01 00:00:01'?
Question25: What information can be used to reliably determine the type of an uploaded file?
Question26: What is the output of the following code?
class Test {
public function __call($name, $args)
{
call_user_func_array(array('static', "test$name"), $args);
}
public function testS($l) {
echo "$l,";
}
}
class Test2 extends Test {
public function testS($l) {
echo "$l,$l,";
}
}
$test = new Test2();
$test->S('A');
Question27: What will be the result of the following operation?
array_combine(array("A","B","C"), array(1,2,3));
Question28: In the following code, which classes can be instantiated?
abstract class Graphics {
abstract function draw($im, $col);
}
abstract class Point1 extends Graphics {
public $x, $y;
function __construct($x, $y) {
$this->x = $x;
$this->y = $y;
}
function draw($im, $col) {
ImageSetPixel($im, $this->x, $this->y, $col);
}
}
class Point2 extends Point1 { }
abstract class Point3 extends Point2 { }
Question29: Given the following DateTime object, which sample will NOT alter the date to the value '2014-02-15'?
$date = new DateTime('2014-03-15');
Question30: An object can be counted with count() and sizeof() if it...
Question31: Which parts of the text are matched in the following regular expression?
$text = <<<EOT
The big bang bonged under the bung.
EOT;
preg_match_all('@b.n?g@', $text, $matches);
Question32: When uploading a file to a PHP script using the HTTP PUT method, where would the file data be found?
Question33: Which of the following is true about stream contexts? (Choose 2)
Question34: Which of the following code snippets is correct? (Choose 2)
Question35: What content-type is required when sending an HTTP POST using JavaScript to ensure that PHP can access the data?
Question36: What is the output of the following code?
class A {
public $a = 1;
public function __construct($a) { $this->a = $a; }
public function mul() {
return function($x) {
return $this->a*$x;
};
}
}
$a = new A(2);
$a->mul = function($x) {
return $x*$x;
};
$m = $a->mul();
echo $m(3);
Question37: SIMULATION
Consider the following code:
$result = $value1 ??? $value2;
Which operator needs to be used instead of ??? so that $result equals $value1 if $value1 evaluates to true, and equals $value2 otherwise? Just state the operator as it would be required in the code.
Question38: Which class of HTTP status codes is used for server error conditions?
Question39: After performing the following operations:
$a = array('a', 'b', 'c');
$a = array_keys(array_flip($a));
What will be the value of $a?
Question40: What is the output of the following code?
function fibonacci (&$x1 = 0, &$x2 = 1)
{
$result = $x1 + $x2;
$x1 = $x2;
$x2 = $result;
return $result;
}
for ($i = 0; $i < 10; $i++) {
echo fibonacci() . ',';
}
Question41: Your application uses PHP to accept and process file uploads. It fails to upload a file that is 5 MB in size, although upload_max_filesize is set to "10M". Which of the following configurations could be responsible for this outcome? (Choose 2)
Question42: Which of the following can NOT be used to send a cookie from within a PHP application?
Question43: Your public web application needs to provide access to binary files for registered users only. How would you achieve this?
Question44: What will the following function call print?
printf('%010.6f', 22);
Question45: From your PHP application, how can you send the same header twice, but with different values?
Question46: What DOMElement method should be used to check for availability of a non-namespaced attribute?
Question47: Which of the following techniques ensures that a value submitted in a form can only be yes or no ?
Question48: What is the output of the following code?
function append($str)
{
$str = $str.'append';
}
function prepend(&$str)
{
$str = 'prepend'.$str;
}
$string = 'zce';
append(prepend($string));
echo $string;
Question49: What is the output of the following code?
class test {
public $value = 0;
function test() {
$this->value = 1;
}
function __construct() {
$this->value = 2;
}
}
$object = new test();
echo $object->value;
Question50: What is the difference between "print" and "echo"?
Question51: SIMULATION
Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP?
Question52: What is the pattern modifier for handling UTF-8 encoded preg_* functionality?
Question53: The XML document below has been parsed into $xml via SimpleXML. How can the value of <foo> tag accessed?
<?xml version='1.0'?>
<document>
<bar>
<foo>Value</foo>
</bar>
</document>
Question54: Assuming UTF-8 encoding, what is the value of $count?
$data = '$1Ä2';
$count = strlen($data);
Question55: Given a PHP value, which sample shows how to convert the value to JSON?
Question56: Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP's ext/json capabilities?
Question57: Given the following array:
$a = array(28, 15, 77, 43);
Which function will remove the value 28 from $a?
Question58: What method can be used to find the tag <any> via the DOM extension?
Question59: What function can reverse the order of values in an array so that keys are preserved?
Question60: What will be the result of the following operation?
$a = array_merge([1,2,3] + [4=>1,5,6]);
echo $a[2];
Question61: Transactions are used to...
Question62: SIMULATION
What is the output of the following code?
function increment ($val)
{
$val = $val + 1;
}
$val = 1;
increment ($val);
echo $val;
Question63: What is the output of the following code?
var_dump(boolval([]));
Question64: Which of the following superglobals does not necessarily contain data from the client?
Question65: Which of the following does NOT help to protect against session hijacking and fixation attacks?
Question66: Which MIME type is always sent by a client if a JPEG file is uploaded via HTTP?
Question67: What will the following code print out?
$str = '✔ one of the following';
echo str_replace('✔', 'Check', $str);
Question68: What function can be used to retrieve an array of current options for a stream context?
Question69: Which of the following functions are used to escape data within the context of HTML? (Choose 2)
Question70: Consider the following two files. When you run test.php, what would the output look like?
test.php:
include "MyString.php";
print ",";
print strlen("Hello world!");
MyString.php:
namespace MyFramework\String;
function strlen($str)
{
return \strlen($str)*2; // return double the string length
}
print strlen("Hello world!")
Question71: Transactions should be used to: (Choose 2)
Question72: Consider the following XML code:
<?xml version="1.0" encoding="utf-8"?>
<books>
<book id="1">PHP 5.5 in 42 Hours</book>
<book id="2">Learning PHP 5.5 The Hard Way</book>
</books>
Which of the following SimpleXML calls prints the name of the second book?
(Let $xml = simplexml_load_file("books.xml"); .) (Choose 2)
Question73: Given the following code, what is correct?
function f(stdClass &$x = NULL) { $x = 42; }
$z = new stdClass;
f($z);
var_dump($z);
Question74: Which of the following is used to find all PHP files under a certain directory?
Question75: Which of the following items in the $_SERVER superglobal are important for authenticating the client when using HTTP Basic authentication? (Choose 2)
Question76: What will the $array array contain at the end of this script?
function modifyArray (&$array)
{
foreach ($array as &$value)
{
$value = $value + 1;
}
$value = $value + 2;
}
$array = array (1, 2, 3);
modifyArray($array);
Question77: What will be the output value of the following code?
$array = array(1,2,3);
while (list(,$v) = each($array));
var_dump(current($array));
Question78: An unbuffered database query will: (Choose 2)
Question79: In a shared hosting environment, session data can be read by PHP scripts written by any user. How can you prevent this? (Choose 2)
Question80: Which of the following methods are available to limit the amount of resources available to PHP through php.ini? (Choose 2)
Question81: Given the following code, what will the output be:
trait MyTrait {
private $abc = 1;
public function increment() {
$this->abc++;
}
public function getValue() {
return $this->abc;
}
}
class MyClass {
use MyTrait;
public function incrementBy2() {
$this->increment();
$this->abc++;
}
}
$c = new MyClass;
$c->incrementBy2();
var_dump($c->getValue());
Question82: Which of the following can be registered as entry points with a SoapServer instance (choose 2):
Question83: What is the output of the following code?
echo "1" + 2 * "0x02";
Question84: How can the id attribute of the 2nd baz element from the XML string below be retrieved from the SimpleXML object
found inside $xml?
<?xml version='1.0'?>
<foo>
<bar>
<baz id="1">One</baz>
<baz id="2">Two</baz>
</bar>
</foo>
Question85: In the following code, which line should be changed so it outputs the number 2:
class A {
protected $x = array(); /* A */
public function getX() { /* B */
return $this->x; /* C */
}
}
$a = new A(); /* D */
array_push($a->getX(), "one");
array_push($a->getX(), "two");
echo count($a->getX());
Question86: Which of the following statements about PHP is false? (Choose 2)
Question87: In order to create an object storage where each object would be stored only once, you may use which of the following? (Choose 2)
Question88: Is the following code vulnerable to SQL Injection ($mysqli is an instance of the MySQLi class)?
$age = $mysqli->real_escape_string($_GET['age']);
$name = $mysqli->real_escape_string($_GET['name']);
$query = "SELECT * FROM `table` WHERE name LIKE '$name' AND age = $age";
$results = $mysqli->query($query);
Question89: What is the return value of the following code: substr_compare("foobar", "bar", 3);
Question90: Which of the following is NOT true about PHP traits? (Choose 2)
Question91: SimpleXML provides the ability to iterate over items in an XML document, as well as access items within it as if they were object properties. When creating your own classes to access data, implementing which of the following would NOT achieve this goal?
Question92: Which of the following PHP functions can be used to set the HTTP response code? (Choose 2)
Question93: What is the output of the following code?
echo "22" + "0.2", 23 . 1;
Question94: Which methods can be used to overload object properties? (Choose 2)
Question95: Which of the following statements is NOT correct?
Question96: Consider the following table data and PHP code. What is the outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna [email protected]
2 betty [email protected]
3 clara [email protected]
5 sue [email protected]
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
$cmd = "SELECT * FROM users WHERE id = :id";
$stmt = $pdo->prepare($cmd);
$id = 3;
$stmt->bindParam('id', $id);
$stmt->execute();
$stmt->bindColumn(3, $result);
$row = $stmt->fetch(PDO::FETCH_BOUND);
Question97: Which of the following rules must every correct XML document adhere to? (Choose 2)
Question98: SIMULATION
Which PHP function sets a cookie and URL encodes its value when sending it to the browser?
Question99: What is the output of the following code?
function z($x) {
return function ($y) use ($x) {
return str_repeat($y, $x);
};
}
$a = z(2);
$b = z(3);
echo $a(3) . $b(2);
Question100: How should you track errors on your production website?
Question101: What is the result of the following bitwise operation in PHP?
1 ^ 2
Question102: An HTML form has two submit buttons. After submitting the form, how can you determine with PHP which button was clicked?
Question103: When using password_hash() with the PASSWORD_DEFAULT algorithm constant, which of the following is true? (Choose 2)
Question104: What is the result of the following code?
define('PI', 3.14);
class T
{
const PI = PI;
}
class Math
{
const PI = T::PI;
}
echo Math::PI;
Question105: The constructs for(), foreach(), and each() can all be used to iterate an object if the object...
Question106: What will the following code piece print?
echo strtr('Apples and bananas', 'ae', 'ea')
Question107: SIMULATION
What is the output of the following code?
function increment ($val)
{
++$val;
}
$val = 1;
increment ($val);
echo $val;
Question108: SIMULATION
Which SPL class implements fixed-size storage?
Question109: Which of the following may be used in conjunction with CASE inside a SWITCH statement?
Question110: What is the length of a string returned by: md5(rand(), TRUE);
Question111: What is the output of the following code?
echo '1' . (print '2') + 3;
Question112: Which of the following statements about anonymous functions in PHP are NOT true? (Choose 2)
Question113: What is the name of the header used to require HTTP authentication?
Question114: What function allows resizing of PHP's file write buffer?
Question115: Which of the following parts must a XML document have in order to be well-formed?
Question116: SIMULATION
Which value will be assigned to the key 0 in this example?
$foo = array(true, '0' => false, false => true);
Question117: What is the recommended method of copying data between two opened files?
Question118: What is the output of the following code?
for ($i = 0; $i < 1.02; $i += 0.17) {
$a[$i] = $i;
}
echo count($a);
Question119: Which of the following statements about exceptions is correct? (Choose 2)
Question120: What is the output of the following code?
class Bar {
private $a = 'b';
public $c = 'd';
}
$x = (array) new Bar();
echo array_key_exists('a', $x) ? 'true' : 'false';
echo '-';
echo array_key_exists('c', $x) ? 'true' : 'false';
Question121: What is the output of this code?
$world = 'world';
echo <<<'TEXT'
hello $world
TEXT;
Question122: What purpose do namespaces fulfill?
Question123: One common security risk is exposing error messages directly in the browser. Which PHP configuration directive can be disabled to prevent this?
Question124: When a browser requests an image identified by an img tag, it never sends a Cookie header.
Question125: How many elements does the $matches array contain after the following function call is performed?
preg_match('/^(\d{1,2}([a-z]+))(?:\s*)\S+ (?=201[0-9])/', '21st March 2014', $matches);
Question126: How can a SimpleXML object be converted to a DOM object?
Question127: The following form is loaded in a recent browser and submitted, with the second select option selected:
<form method="post">
<select name="list">
<option>one</option>
<option>two</option>
<option>three</option>
</select>
</form>
In the server-side PHP code to deal with the form data, what is the value of $_POST['list'] ?
Question128: Under what condition may HTTP headers be set from PHP if there is content echoed prior to the header function being used?
Question129: Which PHP function retrieves a list of HTTP headers that have been sent as part of the HTTP response or are ready to be sent?
Question130: Consider the following table data and PHP code. What is a possible outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna [email protected]
2 betty [email protected]
3 clara [email protected]
5 sue [email protected]
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
$cmd = "SELECT name, email FROM users LIMIT 1";
$stmt = $pdo->prepare($cmd);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_BOTH);
$row = $result[0];
Question131: Which line of code can be used to replace the INSERT comment in order to output "hello"?
class C {
public $ello = 'ello';
public $c;
public $m;
function __construct($y) {
$this->c = static function($f) {
// INSERT LINE OF CODE HERE
};
$this->m = function() {
return "h";
};
}
}
$x = new C("h");
$f = $x->c;
echo $f($x->m);
Question132: What is the output of the following code?
class Base {
protected static function whoami() {
echo "Base ";
}
public static function whoareyou() {
static::whoami();
}
}
class A extends Base {
public static function test() {
Base::whoareyou();
self::whoareyou();
parent::whoareyou();
A::whoareyou();
static::whoareyou();
}
public static function whoami() {
echo "A ";
}
}
class B extends A {
public static function whoami() {
echo "B ";
}
}
B::test();
Question133: SIMULATION
Please provide the name of the super-global variable where all the information about cookies is available.
Question134: You want to parse a URL into its single parts. Which function do you choose?
Question135: An HTML form contains this form element:
<input type="file" name="myFile" />
When this form is submitted, the following PHP code gets executed:
move_uploaded_file(
$_FILES['myFile']['tmp_name'],
'uploads/' . $_FILES['myFile']['name']
);
Which of the following actions must be taken before this code may go into production? (Choose 2)
Question136: Which is the most efficient way to determine if a key is present in an array, assuming the array has no NULL values?
Question137: SIMULATION
What is the name of the key in $_FILES['name'] that contains the number of bytes of the uploaded file?
Question138: You'd like to use the class MyDBConnection that's defined in the MyGreatFramework
\MyGreatDatabaseAbstractionLayer namespace, but you want to minimize *as much as possible* the length of the class name you have to type. What would you do?
Question139: When retrieving data from URLs, what are valid ways to make sure all file_get_contents calls send a certain user agent string? (Choose 2)
Question140: SIMULATION
Which PHP function sets a cookie whose value does not get URL encoded when sending it to the browser?
Question141: What will an opcode cache ALWAYS automatically improve?
Question142: When would you use classes and when would you use namespaces?
Question143: Consider the following code. What change must be made to the class for the code to work as written?
class Magic {
protected $v = array("a" => 1, "b" => 2, "c" => 3);
public function __get($v) {
return $this->v[$v];
}
}
$m = new Magic();
$m->d[] = 4;
echo $m->d[0];
Question144: Which class of HTTP status codes is used for redirections?
Question145: Which of the following statements about Reflection is correct?
Question146: What is the preferred method for preventing SQL injection?
Question147: You want to allow your users to submit HTML code in a form, which will then be displayed as real code and not affect your page layout. Which function do you apply to the text, when displaying it? (Choose 2)
Question148: Which of the following is NOT possible using reflection?
Question149: What is the name of the PHP function used to automatically load non-yet defined classes?
Question150: Which php.ini setting is usually required to use an opcode cache?
Question151: Which of the following filtering techniques prevents all cross-site scripting (XSS) vulnerabilities?
Question152: What is the return value of the following code?
strpos("me myself and I", "m", 2)
Question153: SIMULATION
Consider the following code. Which keyword should be used in the line marked with "KEYWORD" instead of "self" to make this code work as intended?
abstract class Base {
protected function __construct() {
}
public static function create() {
return new self(); // KEYWORD
}
abstract function action();
}
class Item extends Base {
public function action() { echo __CLASS__; }
}
$item = Item::create();
$item->action(); // outputs "Item"
Question154: Which options do you have in PHP to set the expiry date of a session?
Question155: Which of the following will NOT instantiate a DateTime object with the current timestamp?
Question156: How many elements does the array $matches from the following code contain?
$str = "The cat sat on the roof of their house.";
$matches = preg_split("/(the)/i", $str, -1, PREG_SPLIT_DELIM_CAPTURE);
Question157: Which of the following is an invalid DOM save method?
Question158: SIMULATION
Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP, and also save the contents into another folder?
Question159: PHP's array functions such as array_values() can be used on an object if the object...
Question160: SIMULATION
What is the output of the following code?
function increment (&$val)
{
return $val + 1;
}
$a = 1;
echo increment ($a);
echo increment ($a);
Question161: SIMULATION
What is the name of the key for the element in $_FILES['name'] that contains the provisional name of the uploaded file?
Question162: What is the output of the following code?
$f = function () { return "hello"; };
echo gettype($f);
Question163: Which elements does the array returned by the function pathinfo() contain?
Question164: How do you allow the caller to submit a variable number of arguments to a function?
Question165: Which of the following is NOT a valid function declaration?
Question166: Which of the following is NOT a requirement for file uploads to work?
Question167: What does the __FILE__ constant contain?
Question168: Given a php.ini setting of
default_charset = utf-8
what will the following code print in the browser?
header('Content-Type: text/html; charset=iso-8859-1');
echo '✂✔✝';
Question169: You want to access the 3rd character of a string, contained in the variable $test. Which of the following possibilites work? (Choose 2)
Question170: Which of these databases is NOT supported by a PDO driver?
Question171: Which of the following statements is correct?
Question172: What is the output of the following code?
echo 0x33, ' monkeys sit on ', 011, ' trees.';
Question173: SIMULATION
Please provide the value of the $code variable in the following statement to set an HTTP status code that signifies that the requested resource was not found.
http_response_code($code);
Question174: What is the result of the following code?
class T
{
const A = 42 + 1;
}
echo T::A;
Question175: When a class is defined as final it:
Question176: Which of the following statements about SOAP is NOT true?
Question177: How can you determine whether a PHP script has already sent cookies to the client?
Question178: Consider the following code. What can be said about the call to file_get_contents?
$getdata = "foo=bar";
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $getdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://example.com/submit.php', false, $context);
Question179: Before the headers are sent, how can you remove a previously set header?
Question180: What is the output of the following code?
var_dump(boolval(-1));
Question181: What is the output of the following code?
$text = 'This is text';
$text1 = <<<'TEXT'
$text
TEXT;
$text2 = <<<TEXT
$text1
TEXT;
echo "$text2";
Question182: What is the output of the following code?
class Foo Implements ArrayAccess {
function offsetExists($k) { return true;}
function offsetGet($k) {return 'a';}
function offsetSet($k, $v) {}
function offsetUnset($k) {}
}
$x = new Foo();
echo array_key_exists('foo', $x)?'true':'false';
Question183: An HTML form contains this form element:
<input type="image" name="myImage" src="image.png" />
The user clicks on the image to submit the form. How can you now access the relative coordinates of the mouse click?
Question184: Which of the following statements is true?
Question185: Which string will be returned by the following function call?
$test = '/etc/conf.d/wireless';
substr($test, strrpos($test, '/')); // note that strrpos() is being called, and not strpos()
Question186: How many times will the function counter() be executed in the following code?
function counter($start, &$stop)
{
if ($stop > $start)
{
return;
}
counter($start--, ++$stop);
}
$start = 5;
$stop = 2;
counter($start, $stop);
Question187: SIMULATION
Which DOMElement property provides a reference to the list of the element's children?
Question188: What is the output of the following code?
class C {
public $x = 1;
function __construct() { ++$this->x; }
function __invoke() { return ++$this->x; }
function __toString() { return (string) --$this->x; }
}
$obj = new C();
echo $obj();
Question189: Which of the following expressions will evaluate to a random value from an array below?
$array = array("Sue","Mary","John","Anna");
Question190: SIMULATION
What is the output of the following code?
class Number {
private $v = 0;
public function __construct($v) { $this->v = $v; }
public function mul() {
return function ($x) { return $this->v * $x; };
}
}
$one = new Number(1);
$two = new Number(2);
$double = $two->mul()->bindTo($one);
echo $double(5);
Question191: Which of the following statements is NOT true?
Question192: Which of the following functions will allow identifying unique values inside an array?
Question193: Which technique should be used to speed up joins without changing their results?
Question194: Which of the following are NOT acceptable ways to create a secure password hash in PHP? (Choose 2)
Question195: What is the output of the following code?
function increment ($val)
{
$_GET['m'] = (int) $_GET['m'] + 1;
}
$_GET['m'] = 1;
echo $_GET['m'];
Question196: Given the following DateTime objects, what can you use to compare the two dates and indicate that $date2 is the later of the two dates?
$date1 = new DateTime('2014-02-03');
$date2 = new DateTime('2014-03-02');